/**
 * 
 */

$(function() {
	
	
/*				new $.Search({
							source: 'google',
							type : 'news',
							keyword : '美女',
							start : 1,
							callback : function(data) {
								$('#googleApi').append($.tmpl('googleNews',
										data.responseData.results, {
											getUrl: function(){
												return decodeURIComponent(this.data.url);
											}
										}));
							}
						});*/
						
/*				new $.Search({
							source: 'google',
							type : 'images',
							keyword : '美女',
							start : 1,
							callback : function(data) {
								var $div = $('<div>').append(
								$.tmpl('googleImages',
										data.responseData.results, {
											getUrl: function(){
												return decodeURIComponent(this.data.originalContextUrl);
											}
										}));
										$div.dialog({ autoOpen: true, height:300, width:620});
							}
						});*/

				function getXbox(opt) {
					opt = $.extend({name : 'googleNews',
						keyword : opt.keyword,
						callback : function() {
							$.log('callback');
						}
					}, opt);
					new $.ui.Xbox(opt);
				}

	$('#googleNewsTrigger').click(function(){
		getXbox({keyword: '中国', sub: [{keyword: '美女', searchType:'images'}, {keyword:'周惠敏', searchType: 'news'}]});
	});
	
	var highlightWords = ['增强者', '老板', '工作', '改变', '公司', '员工', '制度','思想'];
	
	$('body').highlight(highlightWords, { element: 'patrickHL', className: 'patrickHL'});
	$('body .patrickHL').append('<span class="ui-icon ui-icon-newwin"></span>').hover(function() {
		var keyword = $(this).text();
		var position = [$(this).offset().left + $(this).width() + 10, $(this).offset().top + $(this).width() + 10];
		$.log(position);
		$(this).addClass('patrickHLHover');
		window.getRichBoxTimer = setTimeout(function() {
			getXbox({keyword: keyword, position: position, sub: [{keyword: keyword, searchType: 'news'}, {keyword: keyword, searchType:'images'}, {keyword: keyword, searchType: 'video'}]});
		}, 300);
	},function() {
		$(this).removeClass('patrickHLHover');
		clearTimeout(window.getRichBoxTimer);
	});

/*$('body').mouseup(function() {
	var selection = $.getSelectedText();
	$(selection.node).mouseenter(function() {
		if($.trim(selection.keyword)!= ''){
			getXbox({keyword: selection.keyword, sub: [{keyword: selection.keyword, searchType:'images'}, {keyword: selection.keyword, searchType: 'news'}]});
		}
	});
	
});*/
	
	
	
});